package com.orchard.xpz.utils;

import com.orchard.xpz.entity.sysUser.SysUser;


/**
 * @TaskCode:
 * @description: 储存用户信息
 * @author: minshuai.chen
 * @create: 2022/4/15 15:31
 **/
public class UserRuntime  {
    private static final  ThreadLocal<SysUser> userRutime = new ThreadLocal<>();

    private static SysUser sysuser = new SysUser();
    private UserRuntime(){

    }

    public static void setUser(SysUser user){
        userRutime.set(user);
//        sysuser= user;
    }

    public static SysUser getUser(){
        SysUser user = userRutime.get();
//        SysUser user = sysuser;
        if (null == user){
            throw new RuntimeException("登录失效，请重新登录");
        }
        return user;
    }

    public static void remove(){
        userRutime.remove();
//        sysuser = null;
    }
}
